<!DOCTYPE html>
<html lang="zh-CN" color-mode=light>


<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Nginx 内部变量及其示例值一览 - 树朾的开源技术分享</title>
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  <meta name="google" content="notranslate" />
  <meta name="keywords" content="开源, 分享">
  <meta name="description" content="平时在配置nginx时，时不时需要使用一些内置变量，如...">
  <meta name="author" content="scwang90">
  <link rel="icon" href="/images/icons/favicon.ico">
  
  
  
  
  

  
<link rel="stylesheet" href="/css/style.css">


  
    
<link rel="stylesheet" href="https://at.alicdn.com/t/font_1445822_p6ry5n7lrr.css">

  

  
    
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css">

  

  
    
      
        
        
<link rel="stylesheet" href="https://cdn.bootcss.com/highlight.js/9.18.1/styles/xcode.min.css" name="highlight-style" mode="light">

      
        
        
<link rel="stylesheet" href="https://cdn.bootcss.com/highlight.js/9.18.1/styles/solarized-dark.min.css" name="highlight-style" mode="dark">

      
  

  <script>
    var CONFIG = window.CONFIG || {};
    var ZHAOO = window.ZHAOO || {};
    CONFIG = {
      isHome: false,
      fancybox: true,
      pjax: false,
      loading: {
        gif: '/images/theme/loading.gif',
        lottie: ''
      },
      lazyload: {
        enable: true,
        only_post: 'false',
        loading: {
          gif: '/images/theme/loading.gif',
          lottie: ''
        }
      },
      donate: {
        enable: false,
        alipay: '/images/donate/pay_alipay.jpg',
        wechat: '/images/donate/pay_wxpay.jpg',
        tencent: '/images/donate/pay_tencent.jpg'
      },
      galleries: {
        enable: true
      },
      fab: {
        enable: true,
        always_show: false
      },
      carrier: {
        enable: true
      },
      daovoice: {
        enable: false
      },
      preview: {
        background: {
          default: '',
          api: ''
        },
        motto: {
          default: '我在开了灯的床头下，想问问自己的心啊。',
          typing: true,
          api: 'https://v2.jinrishici.com/one.json',
          data_contents: '["data","content"]'
        },
      },
      qrcode: {
        enable: true,
        type: 'url',
        image: 'https://pic.izhaoo.com/weapp-code.jpg',
      },
      toc: {
        enable: true
      },
      scrollbar: {
        type: 'default'
      },
      notification: {
        enable: false,
        delay: 4500,
        list: '',
        page_white_list: '',
        page_black_list: ''
      },
      search: {
        enable: false,
        path: ''
      }
    }
  </script>

  

  

<meta name="generator" content="Hexo 6.2.0"></head>

<body class="lock-screen">
  <div class="loading" id="loading"></div>
  
    


  <nav class="navbar">
    <div class="left">
      
        <i class="iconfont iconhome j-navbar-back-home"></i>
      
      
        <i class="iconfont iconqrcode j-navbar-qrcode"></i>
      
      
        <i class="iconfont iconmoono" id="color-toggle" color-toggle="light"></i>
      
      
    </div>
    <div class="center">Nginx 内部变量及其示例值一览</div>
    <div class="right">
      <i class="iconfont iconmenu j-navbar-menu"></i>
    </div>
    
      <div id="qrcode-navbar"></div>
    
  </nav>

  
  

<nav class="menu">
  <div class="menu-container">
    <div class="menu-close">
      <i class="iconfont iconbaseline-close-px"></i>
    </div>
    <ul class="menu-content"><li class="menu-item">
        <a href="/ " class="underline "> 首页</a>
      </li><li class="menu-item">
        <a href="/galleries/ " class="underline "> 摄影</a>
      </li><li class="menu-item">
        <a href="/archives/ " class="underline "> 归档</a>
      </li><li class="menu-item">
        <a href="/tags/ " class="underline "> 标签</a>
      </li><li class="menu-item">
        <a href="/categories/ " class="underline "> 分类</a>
      </li><li class="menu-item">
        <a href="/about/ " class="underline "> 关于</a>
      </li></ul>
    
      <div class="menu-copyright"><p>Powered by <a target="_blank" href="https://github.com/scwang90">scwang90</a>  |  Theme - <a target="_blank" href="https://github.com/izhaoo/hexo-theme-zhaoo">zhaoo</a></p> <p><a target="_blank" href="http://beian.miit.gov.cn/"><span>黔ICP备2021004317号-1</span></a><span>  |  </span><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img class="lazyload" data-original="/images/icons/icon-filing.png" src="https://www.beian.gov.cn/img/new/gongan.png"/> <span> 贵公网安备 52010202002539号</span></a></p></div>
    
  </div>
</nav>
  <main id="main">
  <div class="article-wrap">
    
      <!-- 如果当前文章包含名为 "宽屏" 的 tag，则执行此处的 HTML 代码 -->
      <div class="row">
        <div class="col-lg-12 col-xl-1 d-none d-xl-block"></div>
        <div class="col-lg-12 col-xl-10"><article class="article">
  <div class="wrap">
    <section class="head">
  <img   class="lazyload" data-original="/images/theme/post-image.jpg" src=""  draggable="false">
  <div class="head-mask">
    <h1 class="head-title">Nginx 内部变量及其示例值一览</h1>
    <div class="head-info">
      <span class="post-info-item"><i class="iconfont iconcalendar"></i>七月 07, 2023</span>
      
      <span class="post-info-item"><i class="iconfont iconfont-size"></i>16361</span>
    </div>
  </div>
</section>
    <section class="main">
      <section class="content article-entry">
        
          
        
        <h2 id="一、前言"><a href="#一、前言" class="headerlink" title="一、前言"></a>一、前言</h2><p>平时在配置nginx时，时不时需要使用一些内置变量，如 $scheme 变量可以判断请求是 http 还是 https。然而大多数人也只知道几个变量，而对Nginx的其他变量知之甚少，就算看到文档说明也不明觉厉，不知道符不符合自己的需求。于是乎我打算对 Nginx 的大部分变量进行列举与获取它的示例值。</p>
<h2 id="二、变量一览"><a href="#二、变量一览" class="headerlink" title="二、变量一览"></a>二、变量一览</h2><h3 id="1-标准示例"><a href="#1-标准示例" class="headerlink" title="1. 标准示例"></a>1. 标准示例</h3><p>通过查阅文档得出 Nginx 大致包含了下面的变量，包括了 标准示例值和变量说明。</p>
<table>
<thead>
<tr>
<th>英文名</th>
<th>中文名</th>
<th>示例值</th>
<th>变量说明</th>
</tr>
</thead>
<tbody><tr>
<td>$arg_name</td>
<td>请求参数名</td>
<td><code>color=red</code></td>
<td>获取请求URL中的某个特定参数及其值。</td>
</tr>
<tr>
<td>$args</td>
<td>请求参数</td>
<td><code>color=red&amp;size=large</code></td>
<td>提供整个请求URL中“?”后面的所有参数及其值。</td>
</tr>
<tr>
<td>$binary_remote_addr</td>
<td>二进制远程地址</td>
<td><code>0x0A0B0C0D</code></td>
<td>客户端IP地址的二进制表示形式。</td>
</tr>
<tr>
<td>$body_bytes_sent</td>
<td>发送的响应主体字节数</td>
<td><code>12345</code></td>
<td>已发送到客户端的响应主体的总字节数。</td>
</tr>
<tr>
<td>$bytes_sent</td>
<td>发送的总字节数</td>
<td><code>12345</code></td>
<td>包括响应头和主体在内的已发送到客户端的总字节数。</td>
</tr>
<tr>
<td>$connection</td>
<td>连接ID</td>
<td><code>12345</code></td>
<td>当前连接的唯一标识符。</td>
</tr>
<tr>
<td>$connection_requests</td>
<td>连接请求数</td>
<td><code>10</code></td>
<td>在当前连接上处理的请求数量。</td>
</tr>
<tr>
<td>$connection_time</td>
<td>连接持续时间（秒）</td>
<td><code>123.456</code></td>
<td>从建立连接到当前时刻的持续时间（以秒为单位）。</td>
</tr>
<tr>
<td>$content_length</td>
<td>请求内容长度</td>
<td><code>12345</code></td>
<td>请求主体的预期长度（如果存在）。</td>
</tr>
<tr>
<td>$content_type</td>
<td>请求内容类型</td>
<td><code>application/json</code></td>
<td>请求中“Content-Type”头字段指定的内容类型。</td>
</tr>
<tr>
<td>$cookie_name</td>
<td>cookie名</td>
<td><code>user_session=abc123</code></td>
<td>获取请求中名为“name”的特定cookie及其值。</td>
</tr>
<tr>
<td>$document_root</td>
<td>文档根目录</td>
<td><code>/var/www/example.com</code></td>
<td>与当前请求匹配的location块中配置的文档根目录。</td>
</tr>
<tr>
<td>$document_uri</td>
<td>请求URI</td>
<td><code>/index.html</code></td>
<td>完整的请求URI，不包括查询字符串。</td>
</tr>
<tr>
<td>$host</td>
<td>主机头</td>
<td><code>example.com</code></td>
<td>客户端在“Host”头字段中提供的主机名。</td>
</tr>
<tr>
<td>$hostname</td>
<td>服务器主机名</td>
<td><code>webserver01</code></td>
<td>Nginx服务器的主机名。</td>
</tr>
<tr>
<td>$http_name</td>
<td>请求头字段</td>
<td><code>Accept-Language: en-US,en;q=0.5</code></td>
<td>获取请求中名为“name”的特定HTTP头字段及其值。</td>
</tr>
<tr>
<td>$http_host</td>
<td>完整主机头</td>
<td>example.com:80</td>
<td>“Host”请求头的完整值，可能包含端口号</td>
</tr>
<tr>
<td>$http_HEADER</td>
<td>请求头信息</td>
<td>$http_referer</td>
<td>客户端发送的特定请求头信息，例如$http_referer表示referer请求头</td>
</tr>
<tr>
<td>$http_upgrade</td>
<td>HTTP升级头</td>
<td>upgrade</td>
<td>若存在HTTP Upgrade请求头，则显示其值</td>
</tr>
<tr>
<td>$http_user_agent</td>
<td>用户代理</td>
<td>Mozilla&#x2F;5.0…</td>
<td>客户端浏览器信息</td>
</tr>
<tr>
<td>$https</td>
<td>是否HTTPS连接</td>
<td><code>on</code></td>
<td>表示是否为HTTPS连接（“on”或“off”）。</td>
</tr>
<tr>
<td>$is_args</td>
<td>存在参数标记</td>
<td><code>?</code></td>
<td>如果请求包含参数，则为“?”；否则为空字符串。</td>
</tr>
<tr>
<td>$limit_rate</td>
<td>限速速率</td>
<td><code>100k</code></td>
<td>为响应设置的最大传输速率（如：100k）。</td>
</tr>
<tr>
<td>$msec</td>
<td>当前时间（毫秒）</td>
<td><code>1649671538.567</code></td>
<td>从Nginx启动开始到当前时刻的毫秒数。</td>
</tr>
<tr>
<td>$nginx_version</td>
<td>Nginx版本</td>
<td><code>1.18.0</code></td>
<td>Nginx服务器的版本号。</td>
</tr>
<tr>
<td>$pid</td>
<td>进程ID</td>
<td><code>1234</code></td>
<td>处理当前请求的Nginx工作进程的进程ID。</td>
</tr>
<tr>
<td>$pipe</td>
<td>是否管道连接</td>
<td><code>p</code></td>
<td>如果请求通过管道传输，则为“p”；否则为空字符串。</td>
</tr>
<tr>
<td>$proxy_protocol_addr</td>
<td>PROXY协议源地址</td>
<td><code>192.0.2.42</code></td>
<td>使用PROXY协议时，客户端的实际源IP地址。</td>
</tr>
<tr>
<td>$proxy_protocol_port</td>
<td>PROXY协议源端口</td>
<td><code>49152</code></td>
<td>使用PROXY协议时，客户端的实际源端口号。</td>
</tr>
<tr>
<td>$proxy_protocol_server_addr</td>
<td>PROXY协议目的地址</td>
<td><code>198.51.100.1</code></td>
<td>使用PROXY协议时，Nginx监听的服务器地址。</td>
</tr>
<tr>
<td>$proxy_protocol_server_port</td>
<td>PROXY协议目的端口</td>
<td><code>80</code></td>
<td>使用PROXY协议时，Nginx监听的服务器端口号。</td>
</tr>
<tr>
<td>$proxy_protocol_tlv_name</td>
<td>PROXY协议TLV字段名</td>
<td><code>AWS_VPCE_ID</code></td>
<td>获取PROXY协议中的特定TLV字段名及其值。</td>
</tr>
<tr>
<td>$query_string</td>
<td>查询字符串</td>
<td><code>color=red&amp;size=large</code></td>
<td>请求URI中的查询字符串部分（不包括问号“?”）。</td>
</tr>
<tr>
<td>$realpath_root</td>
<td>绝对路径文档根目录</td>
<td><code>/var/www/example.com</code></td>
<td>文档根目录的绝对路径。</td>
</tr>
<tr>
<td>$remote_addr</td>
<td>远程地址</td>
<td><code>192.0.2.42</code></td>
<td>客户端的IP地址。</td>
</tr>
<tr>
<td>$remote_port</td>
<td>远程端口</td>
<td><code>49152</code></td>
<td>客户端的端口号。</td>
</tr>
<tr>
<td>$remote_user</td>
<td>远程用户</td>
<td><code>john.doe</code></td>
<td>已经经过身份验证的用户名（如：基本认证）。</td>
</tr>
<tr>
<td>$request</td>
<td>请求行</td>
<td><code>GET /index.html HTTP/1.1</code></td>
<td>完整的请求行，包括方法、URI和协议版本。</td>
</tr>
<tr>
<td>$request_body</td>
<td>请求主体</td>
<td><code>&#123;&quot;key&quot;: &quot;value&quot;&#125;</code></td>
<td>客户端发送的请求主体数据。</td>
</tr>
<tr>
<td>$request_body_file</td>
<td>请求主体临时文件路径</td>
<td><code>/tmp/nginx_upload_12345</code></td>
<td>存储大请求主体的临时文件路径。</td>
</tr>
<tr>
<td>$request_completion</td>
<td>请求完成状态</td>
<td><code>OK</code></td>
<td>请求处理的完成状态。</td>
</tr>
<tr>
<td>$request_filename</td>
<td>请求文件路径</td>
<td><code>/var/www/example.com/index.html</code></td>
<td>根据请求URI映射到的实际文件系统路径。</td>
</tr>
<tr>
<td>$request_id</td>
<td>请求ID</td>
<td><code>123e4567-e89b-12d3-a456-426655440000</code></td>
<td>为每个请求生成的唯一标识符。</td>
</tr>
<tr>
<td>$request_length</td>
<td>请求长度</td>
<td><code>12345</code></td>
<td>整个请求（包括头和主体）的长度。</td>
</tr>
<tr>
<td>$request_method</td>
<td>请求方法</td>
<td><code>GET</code></td>
<td>客户端使用的HTTP请求方法（如：GET、POST等）。</td>
</tr>
<tr>
<td>$request_time</td>
<td>请求处理时间（秒）</td>
<td><code>0.123</code></td>
<td>从接收请求到发送响应头的时间（以秒为单位）。</td>
</tr>
<tr>
<td>$request_uri</td>
<td>请求URI</td>
<td><code>/index.html?color=red</code></td>
<td>完整的原始请求URI，包括查询字符串。</td>
</tr>
<tr>
<td>$scheme</td>
<td>协议</td>
<td><code>http</code></td>
<td>请求使用的协议（http或https）。</td>
</tr>
<tr>
<td>$sent_http_name</td>
<td>发送的响应头字段</td>
<td><code>Content-Type: application/json</code></td>
<td>发送到客户端的特定响应头字段及其值。</td>
</tr>
<tr>
<td>$sent_trailer_name</td>
<td>发送的响应尾部字段</td>
<td><code>X-Trailer: Value</code></td>
<td>发送到客户端的特定响应尾部字段及其值。</td>
</tr>
<tr>
<td>$server_addr</td>
<td>服务器地址</td>
<td><code>198.51.100.1</code></td>
<td>Nginx服务器监听的IP地址。</td>
</tr>
<tr>
<td>$server_name</td>
<td>服务器名</td>
<td><code>example.com</code></td>
<td>与当前请求匹配的server块的名称。</td>
</tr>
<tr>
<td>$server_port</td>
<td>服务器端口</td>
<td><code>80</code></td>
<td>Nginx服务器监听的端口号。</td>
</tr>
<tr>
<td>$server_protocol</td>
<td>服务器协议</td>
<td><code>HTTP/1.1</code></td>
<td>客户端使用的HTTP协议版本。</td>
</tr>
<tr>
<td>$status</td>
<td>响应状态码</td>
<td><code>200</code></td>
<td>响应给客户端的HTTP状态码。</td>
</tr>
<tr>
<td>$tcpinfo_rtt</td>
<td>TCP往返时间</td>
<td><code>0.050</code></td>
<td>与客户端的TCP连接的往返时间（RTT）。</td>
</tr>
<tr>
<td>$tcpinfo_rttvar</td>
<td>TCP往返时间变化</td>
<td><code>0.010</code></td>
<td>TCP往返时间的变化（RTT variance）。</td>
</tr>
<tr>
<td>$tcpinfo_snd_cwnd</td>
<td>发送方拥塞窗口</td>
<td><code>10000</code></td>
<td>TCP连接的发送方拥塞窗口大小。</td>
</tr>
<tr>
<td>$tcpinfo_rcv_space</td>
<td>接收方缓冲区空间</td>
<td><code>8192</code></td>
<td>TCP连接的接收方缓冲区可用空间。</td>
</tr>
<tr>
<td>$time_iso8601</td>
<td>ISO 8601时间戳</td>
<td><code>2022-0¼-20T14:35:38+00:00</code></td>
<td>当前时间的ISO 8601格式时间戳。</td>
</tr>
<tr>
<td>$time_local</td>
<td>本地时间戳</td>
<td><code>20/Apr/2022:14:35:38 +0000</code></td>
<td>当前时间的本地格式时间戳。</td>
</tr>
<tr>
<td>$uri</td>
<td>请求URI</td>
<td><code>/index.html</code></td>
<td>不包括查询字符串的请求URI。</td>
</tr>
<tr>
<td>$jwt_header_name</td>
<td>JWT头部字段名</td>
<td><code>Authorization: Bearer eyJhbG...</code></td>
<td>获取请求中JWT令牌的特定头部字段及其值。</td>
</tr>
<tr>
<td>$jwt_claim_name</td>
<td>JWT声明字段名</td>
<td><code>sub: john.doe</code></td>
<td>获取JWT令牌中特定声明字段及其值。</td>
</tr>
<tr>
<td>$jwt_payload</td>
<td>JWT有效载荷</td>
<td><code>&#123; &quot;sub&quot;: &quot;john.doe&quot;, &quot;exp&quot;: 16.png&quot;</code></td>
<td>JWT令牌的完整有效载荷对象（JSON格式）。</td>
</tr>
<tr>
<td>$fastcgi_script_name</td>
<td>FastCGI脚本名</td>
<td><code>/index.php</code></td>
<td>当前FastCGI请求的脚本名。</td>
</tr>
<tr>
<td>$fastcgi_path_info</td>
<td>FastCGI路径信息</td>
<td><code>/path/to/resource</code></td>
<td>FastCGI请求中与脚本名后跟的额外路径信息。</td>
</tr>
<tr>
<td>$gzip_ratio</td>
<td>压缩比率</td>
<td><code>0..jpg</code></td>
<td>压缩响应后的实际压缩比率（如：0.5表示压缩了50%）。</td>
</tr>
<tr>
<td>$limit_conn_status</td>
<td>连接限制状态</td>
<td><code>200</code></td>
<td>如果请求因连接限制被拒绝，则返回拒绝状态码；否则为当前响应状态码。</td>
</tr>
<tr>
<td>$limit_req_status</td>
<td>速率限制状态</td>
<td><code>429</code></td>
<td>如果请求因速率限制被拒绝，则返回拒绝状态码；否则为当前响应状态码。</td>
</tr>
<tr>
<td>$memcached_key</td>
<td>Memcached键</td>
<td><code>product_123</code></td>
<td>对于Memcached代理模块，当前请求使用的Memcached键。</td>
</tr>
<tr>
<td>$proxy_host</td>
<td>代理主机名</td>
<td><code>backend.example.com</code></td>
<td>向其转发请求的代理服务器的主机名。</td>
</tr>
<tr>
<td>$proxy_port</td>
<td>代理端口</td>
<td><code>8080</code></td>
<td>向其转发请求的代理服务器的端口号。</td>
</tr>
<tr>
<td>$proxy_add_x_forwarded_for</td>
<td>X-Forwarded-For头</td>
<td><code>client_ip, proxy1_ip, proxy2_ip</code></td>
<td>更新或设置“X-Forwarded-For”头字段，包含客户端及所有上游代理的IP地址。</td>
</tr>
<tr>
<td>$proxy_protocol_tlv_aws_vpce_id</td>
<td>AWS VPC终端节点ID</td>
<td><code>vpce-1234567890abcdef</code></td>
<td>从PROXY协议TLV中获取AWS VPC终端节点ID。</td>
</tr>
<tr>
<td>$proxy_protocol_tlv_azure_pel_id</td>
<td>Azure PEL ID</td>
<td><code>pel-0123456789ABCDEF</code></td>
<td>从PROXY协议TLV中获取Azure PEL（Platform Endpoint Layer）ID。</td>
</tr>
<tr>
<td>$proxy_protocol_tlv_gcp_conn_id</td>
<td>GCP连接ID</td>
<td><code>gcp-conn-1234567890abcdef</code></td>
<td>从PROXY协议TLV中获取GCP连接ID。</td>
</tr>
<tr>
<td>$realip_remote_addr</td>
<td>真实远程地址</td>
<td><code>192.0.2.42</code></td>
<td>根据RealIP模块解析的客户端真实IP地址。</td>
</tr>
<tr>
<td>$realip_remote_port</td>
<td>真实远程端口</td>
<td><code>49152</code></td>
<td>根据RealIP模块解析的客户端真实端口号。</td>
</tr>
<tr>
<td>$invalid_referer</td>
<td>引用头有效性</td>
<td><code>0</code></td>
<td>根据referer有效性检查返回的结果（0表示有效，非0表示无效）。</td>
</tr>
<tr>
<td>$secure_link</td>
<td>加密链接值</td>
<td><code>bS9pbmRleC5odG1sOjEyMzQ=</code></td>
<td>Secure Link模块生成的加密链接值。</td>
</tr>
<tr>
<td>$secure_link_expires</td>
<td>加密链接过期时间</td>
<td><code>164967.png</code></td>
<td>Secure Link模块生成的加密链接过期时间戳。</td>
</tr>
<tr>
<td>$session_log_id</td>
<td>会话日志ID</td>
<td><code>1234567890abcdef</code></td>
<td>会话日志模块为当前请求生成的唯一会话ID。</td>
</tr>
<tr>
<td>$session_log_binary_id</td>
<td>二进制会话日志ID</td>
<td><code>0x1234567890ABCDEF</code></td>
<td>会话日志模块为当前请求生成的二进制会话ID。</td>
</tr>
<tr>
<td>$slice_range</td>
<td>数据切片范围</td>
<td><code>bytes=0-1023</code></td>
<td>范围请求中的数据切片范围。</td>
</tr>
<tr>
<td>$date_local</td>
<td>本地日期时间</td>
<td><code>20/Apr/2022:14:35:38 +0000</code></td>
<td>当前本地日期时间。</td>
</tr>
<tr>
<td>$date_gmt</td>
<td>GMT日期时间</td>
<td><code>20/Apr/2022:14:35:38 +0000</code></td>
<td>当前格林尼治标准时间（GMT）日期时间。</td>
</tr>
<tr>
<td>$ssl_alpn_protocol</td>
<td>ALPN协商协议</td>
<td><code>h2</code></td>
<td>TLS连接上通过ALPN协商选定的应用层协议。</td>
</tr>
<tr>
<td>$ssl_cipher</td>
<td>当前SSL&#x2F;TLS密码套件</td>
<td><code>ECDHE-RSA-AES256-GCM-SHA384</code></td>
<td>当前SSL&#x2F;TLS连接使用的密码套件。</td>
</tr>
<tr>
<td>$ssl_ciphers</td>
<td>允许的SSL&#x2F;TLS密码套件</td>
<td><code>HIGH:!aNULL:!MD5</code></td>
<td>服务器配置中允许的SSL&#x2F;TLS密码套件列表。</td>
</tr>
<tr>
<td>$ssl_client_escaped_cert</td>
<td>客户端证书（URL编码）</td>
<td><code>%30%82...</code></td>
<td>客户端证书的URL编码表示形式。</td>
</tr>
<tr>
<td>$ssl_client_cert</td>
<td>客户端证书</td>
<td><code>-----BEGIN CERTIFICATE-----\nMIID...</code></td>
<td>客户端提供的PEM格式X.509证书。</td>
</tr>
<tr>
<td>$ssl_client_fingerprint</td>
<td>客户端证书指纹</td>
<td><code>SHA1:AB:CD:EF:GH:IJ:KL:M...</code></td>
<td>客户端证书的指纹（如：SHA1）。</td>
</tr>
<tr>
<td>$ssl_client_i_dn</td>
<td>客户端证书issuer DN</td>
<td><code>CN=Example CA, O=Example Org, C=US</code></td>
<td>客户端证书颁发者的DN（Distinguished Name）。</td>
</tr>
<tr>
<td>$ssl_client_i_dn_legacy</td>
<td>客户端证书issuer DN（旧版）</td>
<td><code>/CN=Example CA/O=Example Org/C=US</code></td>
<td>客户端证书颁发者的DN（旧版格式）。</td>
</tr>
<tr>
<td>$ssl_client_raw_cert</td>
<td>客户端证书原始数据</td>
<td><code>0x30820122300D06092A8648...</code></td>
<td>客户端证书的原始二进制数据。</td>
</tr>
<tr>
<td>$ssl_client_s_dn</td>
<td>客户端证书subject DN</td>
<td><code>CN=John Doe, OU=Engineering, O=Example Inc., C=US</code></td>
<td>客户端证书主题的DN。</td>
</tr>
<tr>
<td>$ssl_client_s_dn_legacy</td>
<td>客户端证书subject DN（旧版）</td>
<td><code>/CN=John Doe/OU=Engineering/O=Example Inc./C=US</code></td>
<td>客户端证书主题的DN（旧版格式）。</td>
</tr>
<tr>
<td>$ssl_client_serial</td>
<td>客户端证书序列号</td>
<td><code>1234567890ABCDEF</code></td>
<td>客户端证书的序列号。</td>
</tr>
<tr>
<td>$ssl_client_v_end</td>
<td>客户端证书有效期结束</td>
<td><code>2024-01-01</code></td>
<td>客户端证书的有效期结束日期。</td>
</tr>
<tr>
<td>$ssl_client_v_remain</td>
<td>客户端证书剩余有效期（秒）</td>
<td><code>315360000</code></td>
<td>客户端证书剩余的有效期（以秒为单位）。</td>
</tr>
<tr>
<td>$ssl_client_v_start</td>
<td>客户端证书有效期开始</td>
<td><code>2022-01-01</code></td>
<td>客户端证书的有效期开始日期。</td>
</tr>
<tr>
<td>$ssl_client_verify</td>
<td>客户端证书验证结果</td>
<td><code>SUCCESS</code></td>
<td>客户端证书验证的结果（如：SUCCESS、FAILED等）。</td>
</tr>
<tr>
<td>$ssl_curve</td>
<td>选择的ECDH曲线</td>
<td><code>prime256v1</code></td>
<td>TLS连接上选择的ECDH曲线。</td>
</tr>
<tr>
<td>$ssl_curves</td>
<td>支持的ECDH曲线</td>
<td><code>prime256v1, secp384r1, secp521r1</code></td>
<td>服务器支持的ECDH曲线列表。</td>
</tr>
<tr>
<td>$ssl_early_data</td>
<td>是否使用0-RTT数据</td>
<td><code>on</code></td>
<td>表示是否使用TLS 1.3早期数据（0-RTT）。</td>
</tr>
<tr>
<td>$ssl_protocol</td>
<td>SSL&#x2F;TLS协议版本</td>
<td><code>TLSv1.2</code></td>
<td>当前SSL&#x2F;TLS连接使用的协议版本。</td>
</tr>
<tr>
<td>$ssl_server_name</td>
<td>SNI主机名</td>
<td><code>example.com</code></td>
<td>客户端在Server Name Indication (SNI)扩展中提供的主机名。</td>
</tr>
<tr>
<td>$ssl_session_id</td>
<td>SSL会话ID</td>
<td><code>0123456789ABCDEF</code></td>
<td>当前SSL会话的ID。</td>
</tr>
<tr>
<td>$ssl_session_reused</td>
<td>是否重用SSL会话</td>
<td><code>0</code></td>
<td>表示当前连接是否重用了之前建立的SSL会话（0表示否，非零表示是）。</td>
</tr>
<tr>
<td>$time_iso8601</td>
<td>ISO 8601时间戳</td>
<td><code>2022-0.jpg</code></td>
<td>当前时间的ISO 8601格式时间戳。</td>
</tr>
<tr>
<td>$time_local</td>
<td>本地易读时间戳</td>
<td><code>14/Mar/2022:13:37:05 -0700</code></td>
<td>当前时间的本地易读格式时间戳。</td>
</tr>
<tr>
<td>$upstream_addr</td>
<td>上游服务器地址</td>
<td><code>192.0.2.100:8080, 192.0.2.101:8080</code></td>
<td>与请求关联的上游服务器的地址和端口列表，按请求顺序排列。</td>
</tr>
<tr>
<td>$upstream_bytes_sent</td>
<td>发送给上游的字节数</td>
<td><code>12345</code></td>
<td>发送给上游服务器的总字节数（不包括HTTP头）。</td>
</tr>
<tr>
<td>$upstream_cache_status</td>
<td>缓存命中状态</td>
<td><code>HIT</code></td>
<td>缓存模块返回的缓存状态（如：HIT、MISS、EXPIRED等）。</td>
</tr>
<tr>
<td>$upstream_connect_time</td>
<td>与上游建立连接耗时</td>
<td><code>0.001</code></td>
<td>与上游服务器建立连接所花费的时间（以秒为单位，精确到毫秒）。</td>
</tr>
<tr>
<td>$upstream_header_time</td>
<td>接收上游响应头耗时</td>
<td><code>0.002</code></td>
<td>从开始到接收完上游服务器响应头所花费的时间（以秒为单位，精确到毫秒）。</td>
</tr>
<tr>
<td>$upstream_http_<header></td>
<td>上游HTTP响应头</td>
<td><code>Content-Type: text/html</code></td>
<td>上游服务器返回的特定HTTP响应头（替换<code>&lt;header&gt;</code>为实际头部名称）。</td>
</tr>
<tr>
<td>$upstream_response_length</td>
<td>上游响应长度</td>
<td><code>1234</code></td>
<td>上游服务器返回的响应主体长度（不包括HTTP头）。</td>
</tr>
<tr>
<td>$upstream_response_time</td>
<td>接收上游完整响应耗时</td>
<td><code>0.003</code></td>
<td>从开始到接收完上游服务器完整响应（包括头和主体）所花费的时间（以秒为单位，精确到毫秒）。</td>
</tr>
<tr>
<td>$upstream_status</td>
<td>上游响应状态码</td>
<td><code>200</code></td>
<td>上游服务器返回的HTTP状态码。</td>
</tr>
<tr>
<td>$uri</td>
<td>请求URI</td>
<td><code>/path/to/resource?query=param</code></td>
<td>请求的统一资源标识符（URI），包括查询字符串。</td>
</tr>
<tr>
<td>$uri_args</td>
<td>URI查询参数</td>
<td><code>query=param</code></td>
<td>请求URI中的查询参数部分。</td>
</tr>
<tr>
<td>$uri_hash</td>
<td>请求URI哈希</td>
<td><code>e3b0c44298fc1c149afbf4c899...</code></td>
<td>请求URI的SHA-256哈希值。</td>
</tr>
<tr>
<td>$uri_path</td>
<td>请求URI路径</td>
<td><code>/path/to/resource</code></td>
<td>请求URI中的路径部分，不包括查询字符串。</td>
</tr>
<tr>
<td>$uwsgi_app_id</td>
<td>uWSGI应用ID</td>
<td><code>1</code></td>
<td>uWSGI应用程序的ID。</td>
</tr>
<tr>
<td>$uwsgi_body_bytes_sent</td>
<td>发送至uWSGI的字节数</td>
<td><code>12345</code></td>
<td>发送给uWSGI服务器的总字节数（不包括HTTP头）。</td>
</tr>
<tr>
<td>$uwsgi_chunked</td>
<td>uWSGI响应是否分块</td>
<td><code>0</code></td>
<td>uWSGI响应是否采用分块编码（0表示否，非0表示是）。</td>
</tr>
<tr>
<td>$uwsgi_headers</td>
<td>uWSGI响应头</td>
<td><code>Status: 200</code>、<code>Content-Length: 1234</code></td>
<td>uWSGI服务器返回的所有HTTP响应头，格式化为多个“Name: Value”行。</td>
</tr>
<tr>
<td>$uwsgi_modifier1</td>
<td>uWSGI修饰符1</td>
<td><code>0</code></td>
<td>uWSGI传递给worker的修饰符1值。</td>
</tr>
<tr>
<td>$uwsgi_modifier2</td>
<td>uWSGI修饰符2</td>
<td><code>0</code></td>
<td>uWSGI传递给worker的修饰符2值。</td>
</tr>
<tr>
<td>$uwsgi_num_packets</td>
<td>uWSGI包数量</td>
<td><code>10</code></td>
<td>与请求关联的uWSGI数据包总数。</td>
</tr>
<tr>
<td>$uwsgi_packet_size</td>
<td>uWSGI包大小</td>
<td><code>4096</code></td>
<td>uWSGI数据包的大小（字节）。</td>
</tr>
<tr>
<td>$uwsgi_pid</td>
<td>uWSGI进程ID</td>
<td><code>1234</code></td>
<td>处理请求的uWSGI工作进程的PID。</td>
</tr>
<tr>
<td>$uwsgi_response_code</td>
<td>uWSGI响应状态码</td>
<td><code>200</code></td>
<td>uWSGI服务器返回的HTTP状态码。</td>
</tr>
<tr>
<td>$uwsgi_status</td>
<td>uWSGI状态信息</td>
<td><code>200 OK</code></td>
<td>uWSGI服务器返回的HTTP状态信息。</td>
</tr>
<tr>
<td>$uwsgi_thread_id</td>
<td>uWSGI线程ID</td>
<td><code>1</code></td>
<td>处理请求的uWSGI线程ID（如果适用）。</td>
</tr>
<tr>
<td>$uwsgi_to</td>
<td>uWSGI响应耗时</td>
<td><code>0.001</code></td>
<td>从开始到接收完uWSGI服务器响应所花费的时间（以秒为单位，精确到毫秒）。</td>
</tr>
<tr>
<td>$uwsgi_txid</td>
<td>uWSGI事务ID</td>
<td><code>0123456789ABCDEF</code></td>
<td>uWSGI事务的唯一标识符。</td>
</tr>
</tbody></table>
<p>请注意，这些变量可能需要特定的模块或配置启用才能在实际环境中使用。在编写Nginx配置或日志格式时，请确保已正确配置和启用所需模块，并参考Nginx官方文档以获取最新和最准确的信息。</p>
<h3 id="2-实际获取值"><a href="#2-实际获取值" class="headerlink" title="2. 实际获取值"></a>2. 实际获取值</h3><p>很多时候，文档说是这样，但是实际使用时却有偏差，于是我对变量进行实际测试获取。</p>
<table>
<thead>
<tr>
<th align="left">英文名</th>
<th align="left">中文名</th>
<th align="left">实际获取值</th>
</tr>
</thead>
<tbody><tr>
<td align="left">$pid</td>
<td align="left">进程ID</td>
<td align="left">100</td>
</tr>
<tr>
<td align="left">$uri</td>
<td align="left">请求URI</td>
<td align="left">&#x2F;api&#x2F;backtest</td>
</tr>
<tr>
<td align="left">$scheme</td>
<td align="left">请求协议</td>
<td align="left">https</td>
</tr>
<tr>
<td align="left">$request_uri</td>
<td align="left">完整请求URI</td>
<td align="left">&#x2F;api&#x2F;backtest?tradeId&#x3D;1688653270906431</td>
</tr>
<tr>
<td align="left">$status</td>
<td align="left">响应状态码</td>
<td align="left">000</td>
</tr>
<tr>
<td align="left">$args</td>
<td align="left">查询字符串</td>
<td align="left">tradeId&#x3D;1688653270906431</td>
</tr>
<tr>
<td align="left">$host</td>
<td align="left">主机头</td>
<td align="left">temp.frp.scwang90.cn</td>
</tr>
<tr>
<td align="left">$hostname</td>
<td align="left">主机名</td>
<td align="left">77f1aa4ae276 [docker容器hostname]</td>
</tr>
<tr>
<td align="left">$http_host</td>
<td align="left">完整主机头</td>
<td align="left">temp.frp.scwang90.cn</td>
</tr>
<tr>
<td align="left">$http_HEADER</td>
<td align="left">请求头信息</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$http_upgrade</td>
<td align="left">HTTP升级头</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$http_user_agent</td>
<td align="left">用户代理</td>
<td align="left">Mozilla&#x2F;5.0 (Windows NT 10.0; Win64; x64) AppleWebKit&#x2F;537.36 (KHTML, like Gecko) Chrome&#x2F;114.0.0.0 Safari&#x2F;537.36 Edg&#x2F;114.0.1823.67</td>
</tr>
<tr>
<td align="left">$request_body</td>
<td align="left">请求主体</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$request_filename</td>
<td align="left">真实文件路径</td>
<td align="left">&#x2F;etc&#x2F;nginx&#x2F;html&#x2F;api&#x2F;backtest</td>
</tr>
<tr>
<td align="left">$request_method</td>
<td align="left">请求方法</td>
<td align="left">GET</td>
</tr>
<tr>
<td align="left">$request_time</td>
<td align="left">请求处理时间</td>
<td align="left">0.000</td>
</tr>
<tr>
<td align="left">$content_type</td>
<td align="left">内容类型</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$content_length</td>
<td align="left">内容长度</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$arg_PARAMETER</td>
<td align="left">请求参数</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$query_string</td>
<td align="left">查询字符串</td>
<td align="left">tradeId&#x3D;1688653270906431</td>
</tr>
<tr>
<td align="left">$bytes_sent</td>
<td align="left">已发送字节数</td>
<td align="left">0</td>
</tr>
<tr>
<td align="left">$body_bytes_sent</td>
<td align="left">已发送正文字节数</td>
<td align="left">0</td>
</tr>
<tr>
<td align="left">$connection</td>
<td align="left">连接相关信息</td>
<td align="left">27554</td>
</tr>
<tr>
<td align="left">$connection_requests</td>
<td align="left">连接请求数</td>
<td align="left">4</td>
</tr>
<tr>
<td align="left">$cookie_COOKIE</td>
<td align="left">cookie值</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$document_root</td>
<td align="left">文档根目录</td>
<td align="left">&#x2F;etc&#x2F;nginx&#x2F;html</td>
</tr>
<tr>
<td align="left">$document_uri</td>
<td align="left">文档URI</td>
<td align="left">&#x2F;api&#x2F;backtest</td>
</tr>
<tr>
<td align="left">$limit_rate</td>
<td align="left">限速速率</td>
<td align="left">0</td>
</tr>
<tr>
<td align="left">$remote_addr</td>
<td align="left">客户端IP地址</td>
<td align="left">111.121.67.127</td>
</tr>
<tr>
<td align="left">$remote_port</td>
<td align="left">客户端端口</td>
<td align="left">12882</td>
</tr>
<tr>
<td align="left">$server_addr</td>
<td align="left">服务器IP地址</td>
<td align="left">172.17.0.8</td>
</tr>
<tr>
<td align="left">$server_name</td>
<td align="left">服务器名</td>
<td align="left">*.frp.scwang90.cn</td>
</tr>
<tr>
<td align="left">$server_port</td>
<td align="left">服务器端口</td>
<td align="left">443</td>
</tr>
<tr>
<td align="left">$server_protocol</td>
<td align="left">服务器协议</td>
<td align="left">HTTP&#x2F;1.1</td>
</tr>
<tr>
<td align="left">$date_gmt</td>
<td align="left">GMT日期</td>
<td align="left">Friday, 07-Jul-2023 02:55:28 GMT</td>
</tr>
<tr>
<td align="left">$date_local</td>
<td align="left">本地日期</td>
<td align="left">Friday, 07-Jul-2023 10:55:28 CST</td>
</tr>
<tr>
<td align="left">$time_local</td>
<td align="left">本地时间</td>
<td align="left">07&#x2F;Jul&#x2F;2023:10:55:28 +0800</td>
</tr>
<tr>
<td align="left">$time_iso8601</td>
<td align="left">ISO 8601时间</td>
<td align="left">2023-07-07T10:55:28+08:00</td>
</tr>
<tr>
<td align="left">$realpath_root</td>
<td align="left">解析后的文档根目录</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$nginx_version</td>
<td align="left">Nginx版本</td>
<td align="left">1.23.3</td>
</tr>
<tr>
<td align="left">$binary_remote_addr</td>
<td align="left">二进制远程地址</td>
<td align="left">[开启解析出错]</td>
</tr>
<tr>
<td align="left">$proxy_host</td>
<td align="left">代理主机</td>
<td align="left">httpbin.org</td>
</tr>
<tr>
<td align="left">$proxy_port</td>
<td align="left">代理端口</td>
<td align="left">443</td>
</tr>
<tr>
<td align="left">$proxy_protocol_addr</td>
<td align="left">代理协议地址</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_protocol_port</td>
<td align="left">代理协议端口</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_protocol_tlv_name</td>
<td align="left">代理协议 TLV 名称</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_protocol_tlv_gcp_conn_id</td>
<td align="left">代理协议 TLV GCP 连接 ID</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_protocol_tlv_aws_vpce_id</td>
<td align="left">代理协议 TLV AWS VPCE ID</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_protocol_tlv_azure_pel_id</td>
<td align="left">代理协议 TLV Azure PEL ID</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_protocol_server_addr</td>
<td align="left">代理协议服务器地址</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_protocol_server_port</td>
<td align="left">代理协议服务器端口</td>
<td align="left">[空]</td>
</tr>
<tr>
<td align="left">$proxy_add_x_forwarded_for</td>
<td align="left">添加 X-Forwarded-For 头部</td>
<td align="left">58.16.12.182</td>
</tr>
</tbody></table>
<p>这个实际获取值与上面的标准示例综合对比会对实际应用中有所帮助</p>
<h2 id="三、获取方法"><a href="#三、获取方法" class="headerlink" title="三、获取方法"></a>三、获取方法</h2><p>通过 proxy_set_header 把变量添加到 http Header 中，然后在被代理的服务后端读取出 对应的 Header 值即可获得变量的实际值。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">server &#123;</span><br><span class="line">    # 标准配置 ....</span><br><span class="line"></span><br><span class="line">    # 变量抓取</span><br><span class="line"></span><br><span class="line">    proxy_set_header   Refit-pid                    &quot;=$pid&quot;;                </span><br><span class="line">    proxy_set_header   Refit-uri                    &quot;=$uri&quot;;                </span><br><span class="line">    proxy_set_header   Refit-scheme                 &quot;=$scheme&quot;;             </span><br><span class="line">    proxy_set_header   Refit-request_uri            &quot;=$request_uri&quot;;        </span><br><span class="line">    proxy_set_header   Refit-status                 &quot;=$status&quot;;             </span><br><span class="line">    proxy_set_header   Refit-args                   &quot;=$args&quot;;               </span><br><span class="line">    proxy_set_header   Refit-host                   &quot;=$host&quot;;               </span><br><span class="line">    proxy_set_header   Refit-hostname               &quot;=$hostname&quot;;           </span><br><span class="line">    proxy_set_header   Refit-http_host              &quot;=$http_host&quot;;          </span><br><span class="line">    proxy_set_header   Refit-http_HEADER            &quot;=$http_HEADER&quot;;        </span><br><span class="line">    proxy_set_header   Refit-http_upgrade           &quot;=$http_upgrade&quot;;       </span><br><span class="line">    proxy_set_header   Refit-http_user_agent        &quot;=$http_user_agent&quot;;    </span><br><span class="line">    proxy_set_header   Refit-request_body           &quot;=$request_body&quot;;       </span><br><span class="line">    proxy_set_header   Refit-request_filename       &quot;=$request_filename&quot;;   </span><br><span class="line">    proxy_set_header   Refit-request_method         &quot;=$request_method&quot;;     </span><br><span class="line">    proxy_set_header   Refit-request_time           &quot;=$request_time&quot;;       </span><br><span class="line">    proxy_set_header   Refit-content_type           &quot;=$content_type&quot;;       </span><br><span class="line">    proxy_set_header   Refit-content_length         &quot;=$content_length&quot;;     </span><br><span class="line">    proxy_set_header   Refit-arg_parameter          &quot;=$arg_PARAMETER&quot;;      </span><br><span class="line">    proxy_set_header   Refit-query_string           &quot;=$query_string&quot;;       </span><br><span class="line">    proxy_set_header   Refit-bytes_sent             &quot;=$bytes_sent&quot;;         </span><br><span class="line">    proxy_set_header   Refit-body_bytes_sent        &quot;=$body_bytes_sent&quot;;    </span><br><span class="line">    proxy_set_header   Refit-connection             &quot;=$connection&quot;;         </span><br><span class="line">    proxy_set_header   Refit-connection_requests    &quot;=$connection_requests&quot;;</span><br><span class="line">    proxy_set_header   Refit-cookie_COOKIE          &quot;=$cookie_COOKIE&quot;;      </span><br><span class="line">    proxy_set_header   Refit-document_root          &quot;=$document_root&quot;;      </span><br><span class="line">    proxy_set_header   Refit-document_uri           &quot;=$document_uri&quot;;       </span><br><span class="line">    proxy_set_header   Refit-limit_rate             &quot;=$limit_rate&quot;;         </span><br><span class="line">    proxy_set_header   Refit-remote_addr            &quot;=$remote_addr&quot;;        </span><br><span class="line">    proxy_set_header   Refit-remote_port            &quot;=$remote_port&quot;;        </span><br><span class="line">    proxy_set_header   Refit-server_addr            &quot;=$server_addr&quot;;        </span><br><span class="line">    proxy_set_header   Refit-server_name            &quot;=$server_name&quot;;        </span><br><span class="line">    proxy_set_header   Refit-server_port            &quot;=$server_port&quot;;        </span><br><span class="line">    proxy_set_header   Refit-server_protocol        &quot;=$server_protocol&quot;;    </span><br><span class="line">    proxy_set_header   Refit-date_gmt               &quot;=$date_gmt&quot;;           </span><br><span class="line">    proxy_set_header   Refit-date_local             &quot;=$date_local&quot;;         </span><br><span class="line">    proxy_set_header   Refit-time_local             &quot;=$time_local&quot;;         </span><br><span class="line">    proxy_set_header   Refit-time_iso8601           &quot;=$time_iso8601&quot;;       </span><br><span class="line">    proxy_set_header   Refit-realpath_root          &quot;=$realpath_root&quot;;      </span><br><span class="line">    proxy_set_header   Refit-nginx_version          &quot;=$nginx_version&quot;;      </span><br><span class="line">    proxy_set_header   Refit-binary_remote_addr     &quot;=$binary_remote_addr&quot;; </span><br><span class="line"></span><br><span class="line">    proxy_set_header   Refit-proxy_host                         &quot;=$proxy_host&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_port                         &quot;=$proxy_port&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_addr                &quot;=$proxy_protocol_addr&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_port                &quot;=$proxy_protocol_port&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_tlv_name            &quot;=$proxy_protocol_tlv_name&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_tlv_gcp_conn_id     &quot;=$proxy_protocol_tlv_gcp_conn_id&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_tlv_aws_vpce_id     &quot;=$proxy_protocol_tlv_aws_vpce_id&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_tlv_azure_pel_id    &quot;=$proxy_protocol_tlv_azure_pel_id&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_server_addr         &quot;=$proxy_protocol_server_addr&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_protocol_server_port         &quot;=$proxy_protocol_server_port&quot;;</span><br><span class="line">    proxy_set_header   Refit-proxy_add_x_forwarded_for          &quot;=$proxy_add_x_forwarded_for&quot;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


      </section>
      <section class="extra">
        
          <ul class="copyright">
  
    <li><strong>本文作者：</strong>scwang90</li>
    <li><strong>本文链接：</strong><a href="https://blog.scwang90.cn/2023/07/07/nginx-variable/index.html" title="https:&#x2F;&#x2F;blog.scwang90.cn&#x2F;2023&#x2F;07&#x2F;07&#x2F;nginx-variable&#x2F;index.html">https:&#x2F;&#x2F;blog.scwang90.cn&#x2F;2023&#x2F;07&#x2F;07&#x2F;nginx-variable&#x2F;index.html</a></li>
    <li><strong>版权声明：</strong>本分享所有文章均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" title="BY-NC-SA" target="_blank" rel="noopener">BY-NC-SA</a> 许可协议，转载请注明出处！</li>
  
</ul>
        
        
        
  <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/" rel="tag">nginx</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%AE%BD%E5%B1%8F/" rel="tag">宽屏</a></li></ul> 

        
  <nav class="nav">
    <a href="/2024/03/14/http-html-charset/"><i class="iconfont iconleft"></i>HTML 编码字符集优先级探究</a>
    <a href="/2023/05/23/breakthrough-nginx/">Nginx 难点攻克<i class="iconfont iconright"></i></a>
  </nav>

      </section>
      
    </section>
  </div>
</article></div>
      </div>
    
  </div>
</main>
  

<footer class="footer">
  <div class="footer-social"><a 
        href="tencent://message/?Menu=yes&uin=283371828 "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color= '#12B7F5'" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  iconQQ "></i>
      </a><a 
        href="javascript:; "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color= '#09BB07'" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  iconwechat-fill "></i>
      </a><a 
        href="https://github.com/scwang90 "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color= '#9f7be1'" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  icongithub-fill "></i>
      </a><a 
        href="mailto:scwang90@hotmail.com "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color=#FF3B00" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  iconmail"></i>
      </a></div>
  
    <div class="footer-copyright"><p>Powered by <a target="_blank" href="https://github.com/scwang90">scwang90</a>  |  Theme - <a target="_blank" href="https://github.com/izhaoo/hexo-theme-zhaoo">zhaoo</a></p> <p><a target="_blank" href="http://beian.miit.gov.cn/"><span>黔ICP备2021004317号-1</span></a><span>  |  </span><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img class="lazyload" data-original="/images/icons/icon-filing.png" src="https://www.beian.gov.cn/img/new/gongan.png"/> <span> 贵公网安备 52010202002539号</span></a></p></div>
  
</footer>
  
      <div class="fab fab-plus">
    <i class="iconfont iconplus"></i>
  </div>
  
  
  
  <div class="fab fab-up">
    <i class="iconfont iconcaret-up"></i>
  </div>
  
  
  
    
<script src="/js/color-mode.js"></script>

  
  
</body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>





  
<script src="https://cdn.bootcdn.net/ajax/libs/jquery.lazyload/1.9.1/jquery.lazyload.min.js"></script>




  
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>






  
<script src="https://cdn.bootcdn.net/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>




<script src="/js/utils.js"></script>
<script src="/js/script.js"></script>







  <script>
    (function () {
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      } else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>













</html>